package test128;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-12-18
 * Time: 11:11
 */
public class Main {
    public static void main(String[] args) throws InterruptedException {
        MyThread myThread1 = new MyThread();
        myThread1.start();
        Thread myThread2 = new Thread( new MyThread2());
        myThread2.start();
        System.out.println("主线程执行完毕");

        Thread t3 = new Thread(){
            @Override
            public void run() {
                for (int i = 0; i <10; i++) {
                    System.out.println("线程3正在执行第 "+i+" 次");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        t3.start();
        Thread t4 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i <10; i++) {
                    System.out.println("线程4 正在执行第 "+i+" 次");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
        t4.start();

    }
}
